package com.maiji.cloud.controller.community;

import com.maiji.cloud.controller.BaseController;
import com.maiji.cloud.request.BaseInputDto;
import com.maiji.cloud.request.IdInputDto;
import com.maiji.cloud.request.community.ComCommentMsgInputDto;
import com.maiji.cloud.response.BaseOutPutDto;
import com.maiji.cloud.response.community.ComCommentOutputDto;
import com.maiji.cloud.response.shopingmall.FinancialDetailsResData;
import com.maiji.cloud.utils.Unlogin;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;


import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author ${author}
 * @since 2019-07-12
 */
@RestController
@RequestMapping("/community")
@Api(tags = {"社区"})

public class ComCommentController extends BaseController {


    /**
     *
     * 社区评论通用接口
     * @param inputDto
     * @param maijiToken
     * @return
     */
    @ApiOperation("社区评论通用接口")
    @PostMapping("/comment")
    public BaseOutPutDto<FinancialDetailsResData> comment(@RequestBody BaseInputDto<ComCommentMsgInputDto>inputDto, @RequestHeader("maijiToken")String maijiToken){
        return postForObjectWithToken(maijiToken, REST_URL_PREFIX_COMMUNITY + "/community/comment", inputDto, BaseOutPutDto.class);
    }

    /**
     * 评论动态
     * @param inputDto
     * @param maijiToken
     * @return
     */
    @ApiOperation("评论动态")
    @PostMapping("/commentMsg")
    public BaseOutPutDto<FinancialDetailsResData>commentMsg(@RequestBody BaseInputDto<ComCommentMsgInputDto> inputDto, @RequestHeader("maijiToken")String maijiToken){
        return postForObjectWithToken(maijiToken, REST_URL_PREFIX_COMMUNITY + "/community/commentMsg", inputDto, BaseOutPutDto.class);
    }


    /**
     * 转发动态
     * @param inputDto
     * @param maijiToken
     * @return
     */
    @ApiOperation("转发动态")
    @PostMapping("/transmitMsg")
    public BaseOutPutDto<FinancialDetailsResData>transmitMsg(@RequestBody BaseInputDto<ComCommentMsgInputDto>inputDto,@RequestHeader("maijiToken")String maijiToken){
        return postForObjectWithToken(maijiToken, REST_URL_PREFIX_COMMUNITY + "/community/transmitMsg", inputDto, BaseOutPutDto.class);
    }

    /**
     * 评论其它评论
     * @param inputDto
     * @param maijiToken
     * @return
     */
    @ApiOperation("评论其它评论")
    @PostMapping("/commentComment")
    public BaseOutPutDto<FinancialDetailsResData>commentComment(@RequestBody BaseInputDto<ComCommentMsgInputDto> inputDto,@RequestHeader("maijiToken")String maijiToken){
        return postForObjectWithToken(maijiToken, REST_URL_PREFIX_COMMUNITY + "/community/commentComment", inputDto, BaseOutPutDto.class);
    }

    /**
     * 评论回复
     * @param inputDto
     * @param maijiToken
     * @return
     */
    @ApiOperation("评论回复")
    @PostMapping("/commentReply")
    public BaseOutPutDto<FinancialDetailsResData>commentReply(@RequestBody BaseInputDto<ComCommentMsgInputDto>inputDto,@RequestHeader("maijiToken")String maijiToken){
        return postForObjectWithToken(maijiToken, REST_URL_PREFIX_COMMUNITY + "/community/commentReply", inputDto, BaseOutPutDto.class);
    }

    /**
     * 评论列表
     * @param inputDto
     * @param maijiToken
     * @return
     */
    @Unlogin
    @ApiOperation("评论列表")
    @PostMapping("/commentList")
    public BaseOutPutDto<List<ComCommentOutputDto>>commentList( @RequestBody BaseInputDto<IdInputDto>inputDto, @RequestHeader("maijiToken")String maijiToken){

        return postForObjectWithToken(maijiToken, REST_URL_PREFIX_COMMUNITY + "/community/commentList", inputDto, BaseOutPutDto.class);
    }
    @ApiOperation("评论点赞")
    @PostMapping("/commentPraise")
    public BaseOutPutDto<String>commentPraise(@RequestBody BaseInputDto<IdInputDto>inputDto,@RequestHeader("maijiToken")String maijiToken){

        return postForObjectWithToken(maijiToken, REST_URL_PREFIX_COMMUNITY + "/community/commentPraise", inputDto, BaseOutPutDto.class);

    }
    /**
     * 取消评论点赞
     * @param inputDto
     * @param maijiToken
     * @return
     */
    @ApiOperation("取消评论点赞")
    @PostMapping("/cancelCommentPraise")
    public BaseOutPutDto<String> cancelCommentPraise(@RequestBody BaseInputDto<IdInputDto>inputDto,@RequestHeader("maijiToken")String maijiToken){

        return postForObjectWithToken(maijiToken, REST_URL_PREFIX_COMMUNITY + "/community/cancelCommentPraise", inputDto, BaseOutPutDto.class);
    }


    @ApiOperation("评论删除 用于前端")
    @PostMapping("/commentdelete")
    public BaseOutPutDto<String> commentdelete(@RequestBody BaseInputDto<IdInputDto>inputDto,@RequestHeader("maijiToken")String maijiToken){

        return postForObjectWithToken(maijiToken, REST_URL_PREFIX_COMMUNITY + "/community/commentdelete", inputDto, BaseOutPutDto.class);
    }

}

